package com.atguigu.actual.edu0417.unils;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author: techyang
 * @since: 2023-10-20 08:58
 * @description: 环境工具类
 **/
public class EnvUtil {

    public static void baseEnv(StreamExecutionEnvironment env) {
        // 并行度
        env.setParallelism(4);

        // 检查点相关配置
        // TODO 往doris写数据必须开启检查点
        env.enableCheckpointing(5000L);
        /*
        //2.2 设置检查点超时时间
        env.getCheckpointConfig().setCheckpointTimeout(60000L);
        //2.3 设置job取消之后检查点是否保留
        env.getCheckpointConfig().setExternalizedCheckpointCleanup(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
        //2.4 设置两个检查点之间最小的时间间隔
        env.getCheckpointConfig().setMinPauseBetweenCheckpoints(2000L);
        //2.5 设置重启策略
        // env.setRestartStrategy(RestartStrategies.fixedDelayRestart(3,3000L));
        env.setRestartStrategy(RestartStrategies.failureRateRestart(3, Time.days(30),Time.seconds(3)));
        //2.6 设置状态后端
        env.setStateBackend(new HashMapStateBackend());
        env.getCheckpointConfig().setCheckpointStorage("hdfs://mycluster:8020/edu/ck");
        //2.7 设置操作hadoop的用户
        System.setProperty("HADOOP_USER_NAME","atguigu");*/
    }
}
